<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改谈心谈话记录')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: summernote-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-studenttalk-edit" th:object="${nczxTalkwithStudent}">
            <input name="itemId" th:field="*{itemId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-2 control-label">教师姓名：</label>
                <div class="col-sm-4">
                    <input name="teachername" th:field="*{teachername}" class="form-control" type="text">
                </div>
                <label class="col-sm-2 control-label">教师所属部门：</label>
                <div class="col-sm-4">
                    <select name="teacherorg" class="form-control m-b" th:with="type=${@dict.getType('sys_dept_list')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{teacherorg}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label">学生姓名：</label>
                <div class="col-sm-4">
                    <input name="stuname" th:field="*{stuname}" class="form-control" type="text">
                </div>
                <label class="col-sm-2 control-label">学生性别：</label>
                <div class="col-sm-4">
                    <select name="stusex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{stusex}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label">学生班级：</label>
                <div class="col-sm-4">
                    <input name="stuclass" th:field="*{stuclass}" class="form-control" type="text">
                </div>
                <label class="col-sm-2 control-label">家长联系方式：</label>
                <div class="col-sm-4">
                    <input name="stutell" th:field="*{stutell}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-2 control-label">谈话时间：</label>
                <div class="col-sm-4">
                    <div class="input-group date">
                        <input name="talktime" th:value="${#dates.format(nczxTalkwithStudent.talktime, 'yyyy-MM-dd hh:mm:ss')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
                <label class="col-sm-2 control-label">谈话地点：</label>
                <div class="col-sm-4">
                    <input name="talkplace" th:field="*{talkplace}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">受帮扶学生情况：</label>
                <div class="col-sm-9">
                    <textarea class="form-control" cols="10" rows="6" name="talkresult" th:field="*{talkcontent}"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">帮扶措施及效果：</label>
                <div class="col-sm-9">
                    <textarea class="form-control" cols="10" rows="6" name="talkresult" th:field="*{talkresult}"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">谈话照片：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="talkimg" th:field="*{talkimg}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="talkimg" name="file" type="file">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: summernote-js" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script th:inline="javascript">
        var prefix = ctx + "student/studenttalk";
        $("#form-studenttalk-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-studenttalk-edit').serialize());
            }
        }

        $("input[name='talktime']").datetimepicker({
            format: "yyyy-mm-dd hh:ii:ss",
            autoclose: true
        });
        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
        $(function() {
            $('.summernote').each(function(i) {
                $('#' + this.id).summernote({
                    lang: 'zh-CN',
                    callbacks: {
                        onChange: function(contents, $edittable) {
                            $("input[name='" + this.id + "']").val(contents);
                        },
                        onImageUpload: function(files) {
                            var obj = this;
                            var data = new FormData();
                            data.append("file", files[0]);
                            $.ajax({
                                type: "post",
                                url: ctx + "common/upload",
                                data: data,
                                cache: false,
                                contentType: false,
                                processData: false,
                                dataType: 'json',
                                success: function(result) {
                                    if (result.code == web_status.SUCCESS) {
                                        $('#' + obj.id).summernote('insertImage', result.url);
                                    } else {
                                        $.modal.alertError(result.msg);
                                    }
                                },
                                error: function(error) {
                                    $.modal.alertWarning("图片上传失败。");
                                }
                            });
                        }
                    }
                });
                var content = $("input[name='" + this.id + "']").val();
                $('#' + this.id).summernote('code', content);
            })
        });
    </script>
</body>
</html>